<?php
namespace  common\components\services\customer;
use common\components\extenders\RequestManage;
use common\models\datas\Customer;
use yii\base\Component;

/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2016/4/27
 * Time: 14:42
 */
class Createcard extends Component{

    public static function GenerateCard(){
        $i = 0;
        do{
            $cardnumber = (new RequestManage())->getCardNUmber();
            $c = Customer::find()->where(['card_id'=>$cardnumber])->one();
            if($c == null)$i++;
        }while($i == 0); //如果存在继续生成
        return $cardnumber;
  }
}